package com.glodon.paas.account.biz.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.glodon.paas.account.biz.UserAdviceBiz;
import com.glodon.paas.account.dao.UserAdviceDao;
import com.glodon.paas.account.dao.domain.UserAdviceEntity;
import com.glodon.paas.util.UUIDUtil;

@Component("userAdviceBiz")
public class UserAdviceBizImpl implements UserAdviceBiz {
	@Autowired
	private UserAdviceDao userAdviceDao;
	
	@Override
	public int deleteByPrimaryKey(String id) {
		
		UserAdviceEntity record = new UserAdviceEntity();
		record.setId(id);
		record.setDeleteStatus(-1);
		return userAdviceDao.deleteByPrimaryKey(id);
	}

	@Override
	public UserAdviceEntity insert(UserAdviceEntity record) { 
		if(record.getId() == null){
			record.setId(UUIDUtil.getUUIDStr());
		}
		
		record.setCreateTime(new Date());
		record.setUpdateTime(record.getCreateTime());
		
		userAdviceDao.insert(record);
		return record;
	}

	@Override
	public UserAdviceEntity selectByPrimaryKey(String id) {
		return userAdviceDao.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKey(UserAdviceEntity record) {		 
		return userAdviceDao.updateByPrimaryKey(record);
	}

	@Override
	public List<UserAdviceEntity> queryAdvice(
			String userId, 
			Integer status,
			Integer type, 
			Integer deleteStatus, 
			Integer startIndex,
			Integer count
			) {
		
		return userAdviceDao.queryAdvice(
				userId, 
				status,
				type, 
				deleteStatus, 
				startIndex,
				count);
	}
     
}
